package com.guia_digital;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Point;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;

public class MeuOverlay extends Overlay {

	 private Bitmap imagem;
	 private GeoPoint geopoint;
	 
	 public MeuOverlay(Bitmap img ) {
	   imagem = img;
	 }
	 
	 public void setGeopoint(GeoPoint geopoint) {
	   this.geopoint = geopoint;
	 }
	 
	 @Override
	 public void draw(Canvas canvas, MapView mapView,
	   boolean shadow) {
	   super.draw(canvas, mapView, shadow);

	   if (geopoint != null){
	     Point pontoNaTela = mapView.getProjection()
	       .toPixels(geopoint, null);
	   
	     canvas.drawBitmap(imagem,
	       pontoNaTela.x - (imagem.getWidth() / 2),
	       pontoNaTela.y - (imagem.getHeight()), null);
	   }
	 } 
	}
